require("../less/introduction.less");
require("../lib/iconfont/iconfont.css");
document.ready(function () {
    let userId = window.$utils.istongguo();
    /* 点击返回上一个页面 */
    document.querySelector("#preview").addEventListener("click", function () {
        location.href = "Course.html";

    })
    /* 播放预览视频 */
    document.querySelector("#fanhui").addEventListener("click", function () {
        this.className = "iconfont iconicon_play"
        this.className = "iconfont iconbofang"
        document.querySelector("#video1").play();
        this.parentNode.style.display = "none";
 
    })
         document.querySelector("#video1").addEventListener("ended",function(){
            document.querySelector("#fanhui").parentNode.style.display = "block";
            document.querySelector("#fanhui").className = "iconfont iconicon_play";
        })  
 
        
    /* 配置接口渲染 */
    let cid = sessionStorage.getItem("cid")
    console.log(cid)
    window.$http.get("/sports/courseDetail?id=" + cid, function (res) {
        /* 获取数据并且渲染 */
        console.log(res)
        /* 渲染好了就ok */
        document.querySelector("#video1").src = "http://139.9.177.51:8099" + res.data.fragments[0].videoUrl
        document.querySelector("#abdominalMuscles").textContent = res.data.name;
        document.querySelector("#qianka").textContent = res.data.calorie;
        document.querySelector("#minute").textContent = res.data.time;
        document.querySelector("#dog").src = "http://139.9.177.51:8099" + res.data.imgurl;
        document.querySelector("#desc").textContent = res.data.desc;


        
    /* 点击开始训练 */
    document.querySelector("#button").addEventListener("click",function(){
        /* 把需要的东西存储到本地数据 */
        
        sessionStorage.setItem("fragments",JSON.stringify(res.data.fragments))
        location.href = "coursetraining.html"
    })

    })


})